﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using Steve.UI.Administration.DataAnnotations;
using Steve.UI.Administration.Resources;

namespace Steve.UI.Administration.Models
{
    public sealed class ExistingSiteUrlDetailModel : ExistingRevisedObjectModel
    {
        public ExistingSiteUrlDetailModel()
        {
            this.Rewrites = new List<Tuple<Uri, Guid>>();
        }

        [DataType(DataType.Url)]
        [ReadOnly(true)]
        //[Description("Fully qualified (incl. scheme and authority) url of the page")]
        [Display(ResourceType = typeof(CommonResources), Name = "SiteUrl_Url_Name", Description = "SiteUrl_Url_Description", GroupName = "Basic_GroupName")]
        public Uri Url { get; set; }

        [Show(false, false)]
        public Guid? Id { get; set; }

        //HACK: Commented for now, this doesn't support null as being ok... [LessThan("End")]
        //[Description("Date and time when the url becomes live.  Blank for immediately live.")]
        [Display(ResourceType = typeof(CommonResources), Name = "SiteUrl_Start_Name", Description = "SiteUrl_Start_Description", GroupName = "Basic_GroupName")]
        public DateTime? Start { get; set; }

        //HACK: Commented for now, this doesn't support null as being ok... [GreaterThan("Start")]
        //[Description("Date and time when the url ends being live.  Blank for live indefinitely.")]
        [Display(ResourceType = typeof(CommonResources), Name = "SiteUrl_End_Name", Description = "SiteUrl_End_Description", GroupName = "Basic_GroupName")]
        public DateTime? End { get; set; }

        [Show(false, false)]
        [Display(ResourceType = typeof(CommonResources), Name = "SiteUrl_Rewrites_Name", Description = "SiteUrl_Rewrites_Description", GroupName = "SiteUrl_Rewrites_GroupName")]
        public IEnumerable<Tuple<Uri, Guid>> Rewrites { get; set; }

        //[DisplayName("Ignore query string in matching?")]
        [DataType("YesNo")]
        //[Category("Advanced")]
        [Display(ResourceType = typeof(CommonResources), Name = "SiteUrl_IgnoreQueryString_Name", Description = "SiteUrl_IgnoreQueryString_Description", GroupName = "Advanced_GroupName")]
        public bool IgnoreQueryString { get; set; }
    }
}
